package com.holly.unit.bpmn.designer.enums;

import java.util.Objects;
import java.util.stream.Stream;

/**
 * 类描述: 连续多级主管审批时的终点 枚举类
 *
 * @author fxr
 * @version 1.0.0
 * @date 2022/5/7 9:48
 */
public enum EndConditionEnum {

    // 直到最上层主管的第i级主管
    TOP("TOP"),
    // 不超过发起人的第i级主管
    LEAVE("LEAVE");

    String fieldName;

    EndConditionEnum(String fieldName) {
        this.fieldName = fieldName;
    }

    public String fieldName() {
        return this.fieldName;
    }

    public static EndConditionEnum of(String fieldName) {
        return Stream.of(EndConditionEnum.values())
                .filter(clazz -> Objects.equals(clazz.fieldName(), fieldName))
                .findFirst()
                .orElse(TOP);
    }

}
